package com.yss.controller;

import com.yss.pojo.BondDTO;
import com.yss.pojo.response.ResponseMessage;
import com.yss.service.IBondService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/bond")
public class BondController {

    @Autowired
    private IBondService iBondService;

    @PostMapping("/compute/netty")
    public ResponseMessage<BondDTO> bondDataWithNetty(@RequestBody BondDTO bondDTO) {
        Object result = iBondService.computeBondDataWithNetty(bondDTO);
        if (result instanceof BondDTO) {
            return ResponseMessage.success(result);
        }
        return ResponseMessage.error(result, -1);
    }

    @PostMapping("/compute/rest")
    public ResponseMessage bondDataWithRest(@RequestBody BondDTO bondDTO) {
        return (ResponseMessage) iBondService.computeBondDataWithRest(bondDTO);
    }

}
